package ge.telasi.tasks.ui.task;

import ge.telasi.tasks.model.Task;
import ge.telasi.tasks.ui.UIUtils;
import javax.swing.Icon;

/**
 * @author dimitri
 */
public class TaskDecontationUtils {

    public static Icon getBodyDataIcon(String data) {
        if ("parent_add".equals(data)) {
            return UIUtils.getIcon16x16("feed_add.png");
        } else if ("parent_delete".equals(data)) {
            return UIUtils.getIcon16x16("feed_delete.png");
        } else {
            return UIUtils.getIcon16x16("error.png");
        }
    }

    public static Icon getStatusIcon(Task task) {
        return getStatusIcon(task.getTaskStatus());
    }

    public static Icon getStatusIcon(int taskStatus) {
        switch (taskStatus) {
            case Task.STATUS_DRAFT:
                return UIUtils.getIcon16x16("note.png");
            case Task.STATUS_OPEN:
                return UIUtils.getIcon16x16("application.png");
            case Task.STATUS_PAUSED:
                return UIUtils.getIcon16x16("control_pause.png");
            case Task.STATUS_COMPLETE_OK:
                return UIUtils.getIcon16x16("status_away.png");
            case Task.STATUS_COMPLETE_CANCEL:
                return UIUtils.getIcon16x16("status_busy.png");
            case Task.STATUS_CLOSED_OK:
                return UIUtils.getIcon16x16("accept.png");
            case Task.STATUS_CLOSED_CANCEL:
                return UIUtils.getIcon16x16("cancel.png");
            default:
                return null;
        }
    }

    public static Icon getAttachIcon(Task task) {
        if (task.hasAttachment()) {
            return UIUtils.getIcon16x16("attach.png");
        }
        return null;
    }

    public static Icon getParentIcon() {
        return UIUtils.getIcon16x16("relation_parent.png");
    }

    public static Icon getChildIcon() {
        return UIUtils.getIcon16x16("relation_child.png");
    }

    public static Icon getRelationIcon(Task task) {
        if (task.hasChild() && task.hasParent()) {
            return UIUtils.getIcon16x16("relation_both.png");
        } else if (task.hasChild()) {
            return getParentIcon();
        } else if (task.hasParent()) {
            return getChildIcon();
        }
        return null;
    }

    public static String getPriorityName(int priority) {
        switch (priority) {
            case Task.PRIORITY_HIGH:
                return "მაღალი";
            case Task.PRIORITY_LOW:
                return "დაბალი";
            default:
                return "ჩვეულებრივი";
        }
    }

    public static String getStatusName(int status) {
        switch(status) {
            case Task.STATUS_DRAFT:
                return "წინასწარი";
            case Task.STATUS_OPEN:
                return "ღია";
            case Task.STATUS_PAUSED:
                return "დაპაუზებული";
            case Task.STATUS_COMPLETE_OK:
                return "შესრულებული";
            case Task.STATUS_COMPLETE_CANCEL:
                return "შესრულებული, გაუქმება";
            case Task.STATUS_CLOSED_OK:
                return "დახურული";
            case Task.STATUS_CLOSED_CANCEL:
                return "დახურული, გაუქმება";
            default:
                return "(არა)";
        }
    }

    public static String getRoleLocalizedName(String role) {
        if (Task.ROLE_OWNER.equals(role)) {
            return "მფლობელი";
        } else if (Task.ROLE_ASSIGNEE.equals(role)) {
            return "დაევალა";
        } else if (Task.ROLE_CARBON_COPY.equals(role)) {
            return "ასლი გაეგზავნა";
        } else if (Task.ROLE_FILE_OWNER.equals(role)) {
            return "ფაილის მფლობელი";
        } else if (Task.ROLE_PREPARED_BY.equals(role)) {
            return "მოამზადა";
        } else {
            return role;
        }
    }

}
